<?php

namespace App\Notifications\Wechat;

use App\Exceptions\MsgTemplateNotExistsException;
use EasyWeChat\Factory;

class Notification
{
    private $wechatApp;

    public function __construct()
    {
        $config = config('wechat.official_account');
        $this->wechatApp = Factory::officialAccount($config);
        $this->wechatApp['cache'] = app('easyWechatCache');
    }

    protected function send($openId, $templateId, $url, $data)
    {
        $this->wechatApp->template_message->send([
            'touser' => $openId,
            'template_id' => $templateId,
            'url' => $url,
            'data' => $data
        ]);
    }
}
